<html>
  <head>
    <title>登录点餐系统</title>
	<meta charset="utf-8" />
    <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
    <script src="js/jquery-1.11.3.js"></script>
    <script src="js/bootstrap.js"></script>
  </head>
    <body>
<?php
header('Content-Type:text/html;charset=utf-8');

@$a=$_POST['userName'];
@$b=$_POST['password'];

$PDO=new PDO('mysql:dbname=diancan;charset=UTF8;','root');
$sel=$PDO->prepare('select * from user where userName=:name');
$isok=$sel->execute(array('name'=>$a));

if($isok){
	$bb=$sel->fetchAll(PDO::FETCH_NAMED);
	if($a!=null&&$b!=null){	
		if(empty($bb)){ ?>
				<div class="alert alert-warning alert-dismissible center-block" role="alert" style="width:400px">
				  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				  <strong>错误：</strong>账号不存在！
				</div>
			<?php
		}else{
			if($b==$bb[0]['password']){
				header('Location:diancan.php');
			}else{ ?>
				<div class="alert alert-warning alert-dismissible center-block" role="alert" style="width:400px">
				  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				  <strong>错误：</strong>密码不正确！
				</div>
			<?php }
		}
	}
}
?>
    <div class="modal-dialog">
      <div class="modal-content center-block" style="width:400px">
        <div class="modal-header">
          <div class="modal-title">登录</div>
        </div>
        <form class="form-horizontal" method="post" action="#">
          <div class="modal-body">         
            <div class="form-group">
              <label for="userName" class="control-label col-xs-3">账号</label>
              <div class="col-xs-7">
                <div class="input-group">
                  <span class="input-group-addon" id="basic-addon1">
                  <span class="glyphicon glyphicon-user">
                  </span>
                  </span>
                  <input id ="userName" type="text" class="form-control" name="userName"  required="required" placeholder="请输入用户名">
                </div>
              </div>
            </div>
            <div class="form-group">
              <label for="pwd" class="control-label col-xs-3">密码</label>
              <div class="col-xs-7">
                <div class="input-group">
                  <span class="input-group-addon" id="basic-addon2">
                  <span class="glyphicon glyphicon-lock">
                  </span>
                  </span>
                  <input id="pwd" type="password" class="form-control" name="password" required="required" placeholder="密码">
                </div>
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <button type="submit" class="btn btn-primary" >登录</button>
		    <a href="zc.php" class="btn btn-default">注册</a>
          </div>          
        </form>
      </div>
    </div>
  </body>
</html>